Imports OpenArchive.System

Namespace OpenArchive
    Namespace Document
        Namespace Components
            Public Class IndexComponent
                Inherits Component

                Public Const c_ComponentName As String = "Index"
                Private m_Version As New Version(1, 0)

                'Friend Sub New(ByVal idx As Data.IndexComponentData)
                '	Content = idx
                'End Sub
                Friend Sub New()
                    MyBase.SetComponentName(c_ComponentName)
                    Initialize()
                End Sub
                Friend Sub New(ByVal IndexObject As Object)
                    Me.New()
                    If IndexObject Is Nothing Then
                        Throw New ArgumentException("IndexObject is nothing")
                    End If

                    If ArchiveSystem.VerifyIndexType(IndexObject.GetType) Then
                        ArchiveSystem.System.RegisterIndexType(IndexObject.GetType)
                        DataObjects.Content = IndexObject
                    Else
                        Throw New ArgumentException("Verifing IndexObject failed")
                    End If

                End Sub
                Friend Sub New(ByVal Indexcomponentfromdatabase As Data.IndexComponentData)
                    If m_Version.CompareTo(Indexcomponentfromdatabase.Version) < 0 Then
                        Throw New VersionconflictException()
                    End If
                    DataObjects = Indexcomponentfromdatabase
                End Sub
                Private Sub Initialize()
                    DataObjects = New Data.IndexComponentData()
                    Version = m_Version
                End Sub

                'Public Shadows Property Content() As Document.Indices
                '	Get
                '		Return DirectCast(MyBase.Content, IndexComponentData)
                '	End Get
                '	Set(ByVal value As Docs.Archive.Document.Indices)
                '		MyBase.Content = value
                '	End Set
                'End Property

                Friend Overrides Function IsResponsible(ByVal ComponentDataType As Global.System.Type, ByVal Version As Global.System.Version) As Object
                    Return Type.Equals(ComponentDataType, New Components.Data.IndexComponentData().GetType())
                End Function
                Public Overrides ReadOnly Property IsSingleInstanceType() As Boolean
                    Get
                        Return False
                    End Get
                End Property
            End Class
        End Namespace
    End Namespace
End Namespace